package com.bwie.auth.controller;

import com.bwie.auth.service.AuthService;
import com.bwie.common.domain.User;
import com.bwie.common.domain.request.UserVO;
import com.bwie.common.domain.response.UserResponse;
import com.bwie.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 登录
     */
    @PostMapping("/login")
    public Result<UserResponse> login(@RequestBody UserVO userVO){
        Result<UserResponse> result = authService.login(userVO);
        return result;
    }

    /**
     * 获取token
     */
    @PostMapping("/getInfo")
    public Result<User> getInfo(){
        User info = authService.getInfo();
        Result<User> result = Result.success(info);
        return result;
    }
}
